package com.lucy.wx.miniapp.utils;


import com.lucy.starter.utils.JsonUtil;
import com.lucy.wx.miniapp.dto.MiniAppBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author kindear
 * 小程序会话工具
 */
@Component
public class MiniSessionUtil {
    @Autowired
    HttpServletRequest request;

    /**
     * 获取会话记录的小程序信息
     * @return 小程序基础信息
     */
    public  MiniAppBase getMiniApp(){
        String jsonStr = (String) request.getSession().getAttribute("miniApp");
        return JsonUtil.string2Obj(jsonStr,MiniAppBase.class);
    }
}
